from lib.api.Student import sm
from hytest import GSTORE, STEP, INFO, CHECK_POINT


class Student1:
    name = "添加学生1 - tc002001"

    def teststeps(self):
        STEP(1, "添加学生")

        ret = sm.add_student(username='sun', realname='孙', gradeid=1, classid=GSTORE['七一班-id'], phonenumber="123")
        retAdd = ret.json()

        INFO(retAdd)

        CHECK_POINT("添加学生检查", retAdd['retcode'] == 0)

        self.student_id = retAdd['id']

        STEP(2, "列出学生")

        ret = sm.list_student()
        retList = ret.json()

        INFO(retList)

        CHECK_POINT("列出学生检查", retList['retlist'][0]['id'] == self.student_id)

    def teardown(self):
        sm.delete_student(self.student_id)
